﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:OMANE_Modules_TauxGarantis_ViewModels="clr-namespace:OMANE.Modules.TauxGarantis.ViewModels"
	mc:Ignorable="d"
	x:Class="Views.ViewSimulation"
	d:DesignWidth="640" d:DesignHeight="480">

    <!--<UserControl.DataContext>
        <OMANE_Modules_TauxGarantis_ViewModels:ViewModelSimulation/>
    </UserControl.DataContext>-->

    <UserControl.Resources>
        <Style x:Key="LoadingBarStyle" TargetType="CheckBox">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="CheckBox">
                    	<ControlTemplate.Resources>
                    		<Storyboard x:Key="OnLoaded1" RepeatBehavior="Forever" AutoReverse="False">
                    			<PointAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(LinearGradientBrush.StartPoint)" Storyboard.TargetName="border">
                    				<EasingPointKeyFrame KeyTime="0" Value="1,0.5"/>
                    			</PointAnimationUsingKeyFrames>
                    			<PointAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(LinearGradientBrush.EndPoint)" Storyboard.TargetName="border">
                    				<EasingPointKeyFrame KeyTime="0" Value="0,0.5"/>
                    			</PointAnimationUsingKeyFrames>
                    			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[3].(GradientStop.Offset)" Storyboard.TargetName="border">
                    				<EasingDoubleKeyFrame KeyTime="0" Value="0.04"/>
                    				<EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
                    			</DoubleAnimationUsingKeyFrames>
                    			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[2].(GradientStop.Offset)" Storyboard.TargetName="border">
                    				<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                    				<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.96"/>
                    			</DoubleAnimationUsingKeyFrames>
                    			<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="border">
                    				<EasingColorKeyFrame KeyTime="0" Value="White"/>
                    			</ColorAnimationUsingKeyFrames>
                    			<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="border">
                    				<EasingColorKeyFrame KeyTime="0" Value="White"/>
                    			</ColorAnimationUsingKeyFrames>
                    			<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="border">
                    				<EasingColorKeyFrame KeyTime="0" Value="{StaticResource CoulDefaultWindowTitleFonce}"/>
                    			</ColorAnimationUsingKeyFrames>
                    			<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="border">
                    				<EasingColorKeyFrame KeyTime="0" Value="{StaticResource CoulDefaultWindowTitleFonce}"/>
                    			</ColorAnimationUsingKeyFrames>
                    		</Storyboard>
                    	</ControlTemplate.Resources>
                        <Border   x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="10" d:DesignHeight="25" d:DesignWidth="126"   >
                        	<Border.Background>
                        		<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        			<GradientStop Color="Black" Offset="0"/>
                        			<GradientStop Color="White" Offset="1"/>
                        			<GradientStop Color="#FF7A7A7A" Offset="0.479"/>
                        			<GradientStop Color="#FF838383" Offset="0.515"/>
                        		</LinearGradientBrush>
                        	</Border.Background>   
                            <Border.Visibility>
                                <Binding Path="IsChecked" RelativeSource="{RelativeSource Mode=TemplatedParent}">
                                    <Binding.Converter>
                                        <BooleanToVisibilityConverter />
                                    </Binding.Converter>
                                </Binding>
                            </Border.Visibility>
                         </Border>
                    	<ControlTemplate.Triggers>
                    		<EventTrigger RoutedEvent="FrameworkElement.Loaded">
                    			<BeginStoryboard Storyboard="{StaticResource OnLoaded1}"/>
                    		</EventTrigger>
                    	</ControlTemplate.Triggers>                        
                    </ControlTemplate>
                    
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="100"/>
            <ColumnDefinition Width="5"/>
            <ColumnDefinition MinWidth="100"/>
        </Grid.ColumnDefinitions>
        <TextBlock Grid.Column="2" HorizontalAlignment="Center" />
        <DataGrid ColumnWidth="*"  Grid.Row="1" ItemsSource="{Binding Simulations}" IsSynchronizedWithCurrentItem="True" AutoGenerateColumns="False">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Path=Name}" Header="Nom de la simulation" />
                <DataGridTextColumn Binding="{Binding Time, Mode=OneWay}" IsReadOnly="True" Header="Temps de calcul estimé" />
                <DataGridTextColumn Binding="{Binding Path=ComputationState, Mode=OneWay}" IsReadOnly="True" Header="Etat du calcul" />
                <!--<DataGridTextColumn Binding="{Binding Path=ComputationProgress}" Header="ComputationProgress" />-->
                <!--<DataGridTextColumn Binding="{Binding Path=LaunchCommand, Mode=OneWay}" CanUserSort="False" Header="LaunchCommand" IsReadOnly="True" />-->
                <DataGridTemplateColumn >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid >
                                <!--<Grid.Visibility>
                                    <Binding Path="ShowPb">
                                        <Binding.Converter>
                                            <BooleanToVisibilityConverter />
                                        </Binding.Converter>
                                    </Binding>
                                </Grid.Visibility>-->
                                <Button MinWidth="150" Command="{Binding LaunchCommand}" Content="Lancer">
                                    <Button.Visibility>
                                        <Binding Path="ShowBt" FallbackValue="Collapsed">
                                            <Binding.Converter>
                                                <BooleanToVisibilityConverter />
                                            </Binding.Converter>
                                        </Binding>
                                    </Button.Visibility>
                                </Button>
                             <!--   <ProgressBar Value="{Binding ComputationProgress, Mode=OneWay}">
                                    <ProgressBar.Visibility>
                                        <Binding Path="ShowPb">
                                            <Binding.Converter>
                                                <BooleanToVisibilityConverter />
                                            </Binding.Converter>
                                        </Binding>
                                    </ProgressBar.Visibility>
                                </ProgressBar> !-->
                                <CheckBox MinWidth="75" IsChecked="{Binding ShowPb}" Style="{StaticResource LoadingBarStyle}" >
									  <CheckBox.Visibility>
                                        <Binding Path="ShowPb" >
                                            <Binding.Converter>
                                                <BooleanToVisibilityConverter />
                                            </Binding.Converter>
                                        </Binding>
                                    </CheckBox.Visibility>
								</CheckBox>
                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
        <GridSplitter Grid.Column="1" Grid.RowSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
        <DataGrid Grid.Row="1" Grid.Column="2" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Simulations/Parameters}" AutoGenerateColumns="False" ColumnWidth="*">
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="Parametre">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                           <TextBlock Text="{Binding SelectedVariable, Mode=OneWay}" />                      </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
					<DataGridTemplateColumn.CellEditingTemplate>
						<DataTemplate>
							    <ComboBox ItemsSource="{Binding Path=Variables}" SelectedItem="{Binding SelectedVariable, Mode=OneWayToSource}" />
						</DataTemplate>
					</DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn> 
                <DataGridTextColumn Binding="{Binding Path=Min}" Header="Minimum" />
                <DataGridTextColumn Binding="{Binding Path=Max}"  Header="Maximum" />
                <DataGridTextColumn Binding="{Binding Path=VariationStep}" Header="Incrément" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>